<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019-2-19
  Time: 下午 3:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>AJAX获取数据</title>
    <script lang="javascript" src="../../js/jquery.min.js"></script>
</head>
<body>

<script>
    $(function () {
        // 开始写 jQuery 代码...
        var myHtml = '<table border="1 solid red"><tr><td>ID</td><td>影片</td><td>票房</td></tr>';
        $.ajax({
            url:'test',
            data:null,
            type:'POST',
            dataType:'JSON',
            success:function (myson) {
                $(myson).each(  function (index,film) {
                   myHtml = myHtml + "<tr><td>"+film.id+"</td><td>"+film.filmName+"</td><td>"+film.boxOfficeStr+"</td></tr>";
                });
                myHtml = myHtml + "</table>";
                $('#mydiv').html(  myHtml  );
            },
            error:function (err) {
                alert('服务器繁忙'+err);
            },
            timeout:3000
        });
    });
</script>
<div id="mydiv"></div>
</body>
</html>
